package com.zsrd.self.controller;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.IOException;

public class ResourceLoaderExample {


    private final ResourceLoader resourceLoader;

    public ResourceLoaderExample(ResourceLoader resourceLoader) {
        this.resourceLoader = resourceLoader;
    }

    public void loadResource(String fileName) throws IOException {
        Resource resource = resourceLoader.getResource("classpath:" + fileName);
        File file = resource.getFile();
        String absolutePath = file.getAbsolutePath();

        System.out.println("Absolute Path of the file: " + absolutePath);
    }
}

